`mapHalfDegreeGridToCountries` <-function(dataset,fieldToPlot,...){data(gridExampleData,envir=environment(),package="rworldmap");mapHalfDegreeGridToCountries(get("gridExampleData"),"pa2000.asc",...)}
setGeneric("mapHalfDegreeGridToCountries")

setMethod("mapHalfDegreeGridToCountries",c("character","character"),
function(dataset,fieldToPlot,...){
sGDF<-readAsciiGrid(dataset)
mapHalfDegreeGridToCountries(sGDF,fieldToPlot,...)
}
)

setMethod("mapHalfDegreeGridToCountries",c("SpatialGridDataFrame","character"),
function( dataset
                          ,fieldToPlot
                          ,aggregateOption="sum"  #"mean","max","min"
                          , ...
                         )
   { 

    #can fail without this
    require(sp)
    sGDF <- dataset
    #further checking grid resolution
    if ( gridparameters(sGDF)$cellsize[1]!=0.5 )
    warning(inFile," seems not to be a half degree grid, in mapHalfDegreeGridToCountries()\n")
                         
     #aggregate the data to countries (pass the sGDF because already read in above)
     dF <- aggregateHalfDegreeGridToCountries(inFile=sGDF, aggregateOption=aggregateOption)
     
     #call map plotting function
     mapCountryData( dataset=dF
                  , fieldToPlot = names(dF)[2]
                  , joinCode="UN"
                  , nameJoinColumn="UN"
                  ,...
                  )
                         
                         
    } #end of mapHalfDegreeGridToCountries()
    )
